
<script lang="ts" setup>
import { pinia, useMenusStore } from '@stores'
import { storeToRefs } from 'pinia'

import router from '@router'
import { useLocalStorage } from '@/hooks/useLocalStorage'
import LocalDropDown from './comp/LocalDropDown.vue'
import FullScreen from './comp/FullScreen.vue'
import AppTheme from '../app-theme'


const menusStore = useMenusStore(pinia)

const { state: user } = useLocalStorage('user')

const { collapse } = storeToRefs(menusStore)
function changeCollapse() {
  menusStore.collapse = !menusStore.collapse
}
const goLogin = () => {
  router.push('/login')
}

const goHome = () => {
  router.push('/home')
}
</script>

<template>
  <el-header class="layout-header" >
    <el-icon color="#888" @click="changeCollapse" style="cursor: pointer">
      <Expand v-if="collapse" />
      <Fold v-else />
    </el-icon>
    <div class="user-card">
      <full-screen />
      <el-divider direction="vertical" style="height: 36px;margin-top: 0px"/>
      <LocalDropDown />
      <el-divider direction="vertical" style="height: 36px;margin-top: 0px"/>
      <app-theme />
      <el-divider direction="vertical" style="height: 36px;margin-top: 0px"/>
      <el-dropdown>
        <el-row>
          <el-avatar
            style="margin-right: 8px; width: 30px; height: 30px;margin-top: 3px"
            src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
          />
          <span class="user-name">{{ user.userName }}</span>
        </el-row>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item @click="goLogin">退出登陆</el-dropdown-item>
            <el-dropdown-item @click="goHome">首页</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </el-header>
</template>

<style lang="scss" scoped>
:focus-visible {
  outline: none;
}
</style>
